package com.example.wuqujingdianphone.fragment.mainfragment;

import android.content.Intent;
import android.os.Bundle;
import android.support.design.widget.TabLayout;
import android.support.v4.app.Fragment;
import android.support.v4.view.ViewPager;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.example.wuqujingdianphone.R;
import com.example.wuqujingdianphone.activity.LoginActivity;
import com.example.wuqujingdianphone.activity.MainActivity;
import com.example.wuqujingdianphone.adapter.BookRackPagerAdapter;
import com.example.wuqujingdianphone.utils.SPUtil;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.Unbinder;

/**
 * Created by yuanpk on 2018/4/9.
 */

public class BookRackFragment extends Fragment {
    private static final String TAG = "BookRackFragment";
    @BindView(R.id.tabLayout)
    TabLayout mTabLayout;
    @BindView(R.id.viewPager)
    ViewPager mViewPager;
    Unbinder unbinder;

    private BookRackPagerAdapter mPagerAdapter;

    @BindView(R.id.title)
    TextView title;

    public static BookRackFragment getBookRackFragment() {
        BookRackFragment fragment = new BookRackFragment();
        return fragment;
    }


    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.fragment_book_rack, container,false);
        unbinder = ButterKnife.bind(this, view);
//        TextView textView = (TextView) getActivity().findViewById(R.id.title);
        title.setText("书架");



        initView();

        return view;
    }

    private void initView() {
        Log.i(TAG, "initView: ");
        mPagerAdapter = new BookRackPagerAdapter(getChildFragmentManager());
        mViewPager.setAdapter(mPagerAdapter);
        mTabLayout.setupWithViewPager(mViewPager);

    }


    @Override
    public void onDestroyView() {
        super.onDestroyView();
        unbinder.unbind();
    }
}
